<script>
    $().ready(function(){
        $('select[name=txt_active]').change(function(){
            var active = $(this).val();
             var id = $(this).attr('id');             
             $.ajax({
                type : "GET",
                dataType : "json",
                url : "<?php echo base_url().'admin/news_product/change_update_active'?>",
                data : 'id=' + id + '&active=' + active,
                success : function(result){
                    alert(result.error);
                    return false;
                }
            });
        });        
    });
</script>

<div class="info">
<h1 class="font_h1">Danh sách sản phẩm</h1>
<?php if(isset($error))  : ?>
<h2 class="error_red"><?php echo $error;?></h2>
<?php endif;?>
<table cellpadding="0" cellspacing="0" style="background:#FFF; color:#000;">
        <tr class="tr">
        	<td><input type="checkbox" value=""></td> 
            <td>Hình</td>
            <td>Tên</td>
                       
            <td>Url</td>
             <td>Hiển thị</td>
            <td>Vị trí</td>
            <td>#</td>
        </tr>
        
        <?php
			
			foreach($show as $row){
		?>
        <tr style="text-align:center">
            	<td><input type="checkbox" value=""></td> 
            	
                <td><img style="width:100px; height:100px" src="<?php echo base_url()?><?php echo $row->image_thumb ;?>" /></td>
                <td><?php echo $row->title;?></td>
                
                 <td><?php echo $row->url;?></td>
                <td>
                <select name="txt_active" id="<?php echo $row->id_news_product;?>" style="width:120px">
                	<option value="1"<?php if($row->active == '1') echo "selected";?>>Hiển thị</option>
                    <option value="0"<?php if($row->active == '0') echo "selected";?> >Không hiện thị</option>
                </select>
                </td>
                <td>
				
				<?php if($row->vitri_show == '0') {
					echo "Không";
				} else if($row->vitri_show == '1') {
					echo "Trang chủ";
				} else if($row->vitri_show == '2') {
					echo "Bên trái";
				} else  {
					echo "Bên phải";
				}
				
				?></td>
                <td>
                <a href="<?php echo base_url().'admin/news_product/add_update/'.$row->id_news_product;?>" title="Edit"><img src="<?php echo base_url()?>public/admin/images/user_edit.png"></a>&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url().'admin/news_product/delete_news/'.$row->id_news_product;?>" title="Delete"><img src="<?php echo base_url()?>public/admin/images/trash.png"></a>
                </td>
                
               
            </tr>
        <?php } ?>
</table>   
<table class="phantrang">
    <tr>
        <td><?php echo $page;?></td>
    </tr>
</table>
<a href="" class="button">Xóa bản tin đã chọn</a>
<a href="<?php echo base_url()?>admin/product/add_update" class="button">Tạo mới</a>
   
</div>  